<template>
	<view class="container">
		<view class="top_box">
			<view class="left">
				<view class="small">累计收益</view>
				<view class="big">{{qiInfo.sumbrokerage}}</view>
			</view>
			<view class="right">
				<view class="small">可提现</view>
				<view class="big rights">{{qiInfo.brokerage_price}}
					<view class="tx_btn" @click="$gourl('/riderMine/extract')">提现</view>
				</view>
			</view>
		</view>
		<view class="bottom_box">
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#EA3D37"
				tabbarBgImg="/icons/bar.png"></u-tabs>
			<view class="content">
				<view v-for="(item,index) in dataList" :key="index">
					<view class="time">{{item.time}}</view>
					<view class="list" v-for="(item2,index2) in item.list" :key="index2">
						<view class="con_left">
							<view class="da">{{item2.title}}</view>
							<view class="xiao">{{item2.add_time}}</view>
						</view>
						<view class="con-right">{{item2.pm==0?'-':'+'}}{{item2.number}} <text>元</text></view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '推广收益'
				}],
				current: 0,
				page: 1,
				type: 3,
				dataList: [],
				qiInfo: null,
			}
		},
		onShow() {
			this.getQiInfo()
		},
		onLoad(opdata) {
			console.log(opdata);
			if (opdata) {
				if (Number(opdata.type) == 1) {
					this.type = 3
					this.list = [{
						name: '推广收益'
					}]
				} else {
					this.type = 5
					this.list = [{
						name: '骑手收益'
					}, {
						name: '推广收益'
					}]
				}
			}
			this.getIncome()
		},
		methods: {
			getQiInfo() {
				this.$allApi.getQiInfo().then(res => {
					this.qiInfo = res.data
				})
			},
			getIncome() {
				let query = {
					type: this.type,
					data: {
						page: this.page,
						limit: 15,
					}
				}
				this.$allApi.getIncome(query).then(res => {
					this.dataList = res.data
				})
			},
			change(e) {
				this.current = e
				if (Number(e) == 0) {
					this.type = 5
				} else {
					this.type = 3
				}
				this.page = 1
				this.dataList = []
				this.getIncome()
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {

		// border-top: 1px solid #eee;
		.list {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx 0;
			line-height: 2;

			.con_left {
				.da {
					font-size: 24rpx;
				}

				.xiao {
					font-size: 20rpx;
					color: #666;
				}
			}

			.con-right {
				color: #EA3D37;
				font-size: 40rpx;

				text {
					font-size: 24rpx;
				}
			}
		}
	}

	.bottom_box {
		width: 710rpx;
		background: #fff;
		padding: 20rpx;
		border-radius: 20rpx;
		margin: 0 auto;
		margin-top: 20rpx;
	}

	.top_box {
		width: 710rpx;
		height: 128rpx;
		background: #fff;
		margin: 0 auto;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 16rpx 0;

		.left,
		.right {
			flex: 1;
			text-align: center;
		}

		.small {
			font-size: 24rpx;
		}

		.big {
			font-size: 28rpx;
		}

		.rights {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;

			.tx_btn {
				width: 76rpx;
				height: 32rpx;
				opacity: 1;
				border-radius: 84rpx;
				border: 1rpx solid #EA3D37;
				color: #EA3D37;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 20rpx;
				margin-left: 10rpx;
			}
		}

		.left {
			border-right: 1px solid #ECECEC;
		}

	}

	.container {
		min-height: 100vh;
		background: #f8f8f8;
		padding: 20rpx;
	}
</style>